package com.demo.apparel.controller.web;

import com.demo.apparel.dto.web.AdminFeedbackDTO;
import com.demo.apparel.dto.ReplyFeedbackDTO;
import com.demo.apparel.service.web.FeedbackService;
import com.demo.apparel.vo.PageVO;
import com.demo.apparel.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/web/feedback")
@Tag(name = "用户反馈信息接口", description = "用户反馈信息")
public class AdminFeedbackController {

    @Autowired
    private FeedbackService feedbackService;


    @PostMapping("/list")
    @Operation(summary = "获取用户反馈信息")
    public Result<PageVO<AdminFeedbackDTO>> getFeedbackList(@RequestBody FeedbackQuery query) {
        PageVO<AdminFeedbackDTO> pageVO = feedbackService.getFeedbackPage(
                query.getStatus(), query.getContact(), query.getPageNum(), query.getPageSize()
        );
        return Result.success(pageVO);
    }

        @Data
        public static class FeedbackQuery {
            private Integer status;
            private int pageNum = 1;
            private int pageSize = 10;
            private String contact;
        }

    @PostMapping("/reply")
    @Operation(summary = "反馈用户")
    public Result<Void> replyFeedback(@RequestBody ReplyFeedbackDTO dto) {
        feedbackService.replyFeedback(dto);
        return Result.success();
    }


    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除反馈")
    public Result<Void> deleteFeedback(@PathVariable("id") String feedbackId) {
        feedbackService.deleteFeedback(feedbackId);
        return Result.success();
    }


    @DeleteMapping("/delete")
    @Operation(summary = "批量删除反馈")
    public Result<Void> deleteFeedbackBatch(@RequestBody IdsRequest request) {
        feedbackService.deleteFeedbackBatch(request.getId());
        return Result.success();
    }

    @Data
    public static class IdsRequest {
        private List<String> id;
    }


}
